package com.tender.desensitization.factory.instance;

import java.util.ArrayList;
import java.util.List;

public class TypeProcessFactoryFacade {

    List<TypeProcessFactory> factoryList = new ArrayList<>();

    public TypeProcessFactoryFacade() {
        factoryList.add(new ListProcessFactory(this));
        factoryList.add(new MapProcessFactory(this));
        factoryList.add(new SetProcessFactory(this));
    }

    public TypeProcessFactory getProcessFactory(Class<?> clazz) {
        return factoryList.stream().filter(item -> item.supports(clazz)).findFirst().orElse(null);
    }

    public void setTypeProcessFactory(TypeProcessFactory typeProcessFactory) {
        factoryList.add(typeProcessFactory);
    }
}
